package com.tensquare.consumer.listener;

import com.aliyuncs.exceptions.ClientException;
import com.tensquare.consumer.utils.SmsUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RabbitListener(queues = "sms")
public class CodeListener {
    @Autowired
    private SmsUtil smsUtil;
    @RabbitHandler
    public void Sms(Map<String,String> map){
        try {
            String mobile = map.get("mobile");
            String param = map.get("param");
            String signName = map.get("signName");
            String templateCode=map.get("templateCode");
            System.out.println("param = " + param);
            smsUtil.sendSms(mobile,templateCode,signName,param);
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}
